﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using OS.GenericDashboardViewer.ViewModels;
using Microsoft.Practices.Unity;
using OS.GenericDashboardViewer.Infrastructure;
using OS.GenericDashboardViewer.Interfaces;
using OS.GenericDashboardViewer.BL;
using OS.GenericDashboardViewer.DataModel;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Input;
using System.Collections.ObjectModel;

namespace OS.GenericDashboardViewer
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
          
            base.OnStartup(e);

            var container = InitContainer();
            var viewPartsConfiguration = container.Resolve<IPartViewsConfigurationMgr>().LoadViewPartsConfiguration();

           
            container.RegisterInstance<IViewPartsConfiguration>(viewPartsConfiguration);
            var win = new MainWindow();
           
            win.DataContext = container.Resolve<ViewPartViewModel>();
            win.Show();

     
        }

        private IUnityContainer InitContainer()
        {
            UnitySingleton.Instance.UnityContainer.RegisterType<IPartViewsConfigurationMgr, PartViewsConfigurationMgr>(new ContainerControlledLifetimeManager());

            return UnitySingleton.Instance.UnityContainer;
        }
    }
}
